package net.flydy.ywxcx.wxcloudrun.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @author flydy
 */
@Component
public class ConfigService {

    @Autowired
    private Environment environment;

    public boolean isDebug() {
        String debug = getEnvConfig("debug", "1");
        return  "1".equals(debug);
    }

    public String getEnvConfig(String key, String defaultV) {
        return environment.getProperty(key, defaultV);
    }
    public int getEnvConfig(String key, int defaultV) {
        return environment.getProperty(key, Integer.class, defaultV);
    }

    public long getEnvConfig(String key, long defaultV) {
        return environment.getProperty(key, Long.class, defaultV);
    }

}
